package com.kmxd.ams.client.oss.vo;

import cn.hutool.core.io.unit.DataSizeUtil;
import cn.hutool.core.util.StrUtil;
import com.alibaba.excel.annotation.ExcelIgnoreUnannotated;
import com.alibaba.excel.annotation.ExcelProperty;
import com.alibaba.excel.annotation.write.style.*;
import com.alibaba.excel.enums.poi.HorizontalAlignmentEnum;
import com.fasterxml.jackson.annotation.JsonFormat;
import com.fasterxml.jackson.databind.annotation.JsonSerialize;
import com.fasterxml.jackson.databind.ser.std.ToStringSerializer;
import io.swagger.v3.oas.annotations.media.Schema;
import java.io.Serializable;
import java.util.Date;
import lombok.Data;
import org.springframework.format.annotation.DateTimeFormat;

/**
 * 公共附件表
 *
 * @author ZuoLG
 * @since 2022-07-25
 */
@Data
@ColumnWidth(15)
@HeadRowHeight(15)
@ContentRowHeight(15)
@HeadStyle
@HeadFontStyle(fontHeightInPoints = 12)
@ContentStyle(horizontalAlignment = HorizontalAlignmentEnum.CENTER)
@ContentFontStyle(fontHeightInPoints = 10)
@ExcelIgnoreUnannotated
@Schema(description = "公共附件表对象")
public class OssAttachmentListVO implements Serializable {

  private static final long serialVersionUID = 1L;

  @Schema(description = "主键ID")
  @JsonSerialize(using = ToStringSerializer.class)
  @ExcelProperty(value = "主键ID")
  private Long id;

  @Schema(description = "公司ID")
  @JsonSerialize(using = ToStringSerializer.class)
  @ExcelProperty(value = "公司ID")
  private Long comId;

  @Schema(description = "全宗ID")
  @JsonSerialize(using = ToStringSerializer.class)
  @ExcelProperty(value = "全宗ID")
  private Long fondsId;

  @Schema(description = "附件所属业务 公告:notice,专题subject 盘点")
  @ExcelProperty(value = "附件所属业务 公告:notice,专题subject 盘点")
  private String type;

  @Schema(description = "附件名称")
  @ExcelProperty(value = "附件名称")
  private String name;

  @Schema(description = "附件扩展名")
  @ExcelProperty(value = "附件扩展名")
  private String ext;

  /** 使用路径 */
  @Schema(description = "使用路径")
  @ExcelProperty(value = "使用路径")
  private String defPath;

  @Schema(description = "附件大小")
  @ExcelProperty(value = "附件大小")
  private String fileSize;

  @Schema(description = "附件大小格式化")
  @ExcelProperty(value = "附件大小格式化")
  private String fileSizeStr;

  @Schema(description = "附件保存路径")
  @ExcelProperty(value = "附件保存路径")
  private String path;

  @Schema(description = "业务关联id")
  @JsonSerialize(using = ToStringSerializer.class)
  @ExcelProperty(value = "业务关联id")
  private Long pid;
  @Schema(description = "根路径")
  @ExcelProperty(value = "根路径")
  private String rootPath;
  @Schema(description = "转换之后的文件名")
  @ExcelProperty(value = "转换之后的文件名")
  private String showFileName;
  @Schema(description = "转换之后的路径")
  @ExcelProperty(value = "转换之后的路径")
  private String transferPath;
  @Schema(description = "附件转换状态")
  @ExcelProperty(value = "附件转换状态")
  private Long transferStatus;
  @Schema(description = "状态")
  @ExcelProperty(value = "状态")
  private Long status;
  @Schema(description = "创建人")
  @JsonSerialize(using = ToStringSerializer.class)
  @ExcelProperty(value = "创建人")
  private Long createBy;
  @Schema(description = "创建时间")
  @JsonFormat(timezone = "GMT+8", pattern = "yyyy-MM-dd HH:mm:ss")
  @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
  @ColumnWidth(20)
  @ExcelProperty(value = "创建时间")
  private Date createTime;
  @Schema(description = "更新人")
  @JsonSerialize(using = ToStringSerializer.class)
  @ExcelProperty(value = "更新人")
  private Long updateBy;
  @Schema(description = "更新时间")
  @JsonFormat(timezone = "GMT+8", pattern = "yyyy-MM-dd HH:mm:ss")
  @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
  @ColumnWidth(20)
  @ExcelProperty(value = "更新时间")
  private Date updateTime;

  public String getFileSizeStr() {
    return DataSizeUtil.format(StrUtil.isNotBlank(fileSize) ? Long.parseLong(fileSize) : 0L);
  }
}
